const { Category } = require('../../model/Category');
module.exports = async (req,res)=> {
  let category = await Category.findOne({title: req.body.title});
  if (category) {
    res.redirect('/admin/categories');
  } else {
    await Category.create({
      title: req.body.title,
      createTime: Date.now()
    });
    res.redirect('/admin/categories');
  }
}